﻿using System.Windows;
using System.Windows.Controls;
using QDP.Platform.Silverlight.Controls;
using QDP.Platform.Silverlight.Manager;

namespace Demos
{
    public partial class Demo0000 : UserControl
    {
        public Demo0000()
        {
            InitializeComponent();
            Q.EventMonitor.Closeing += new System.EventHandler<WidgetEventArgs>(EventMonitor_WidgetCloseing);
            Q.EventMonitor.Minimizing += new System.EventHandler<WidgetEventArgs>(EventMonitor_WidgetMinimized);
            Q.EventMonitor.Showing += new System.EventHandler<WidgetEventArgs>(EventMonitor_WidgetShowing);
        }

        void EventMonitor_WidgetShowing(object sender, WidgetEventArgs e)
        {
            if ((sender as WidgetControl).Child.GetHashCode() == this.GetHashCode())// 确定当前触发事件的内容为自身
            {
                MessageBoxResult result = MessageBox.Show("是否可以打开窗口？", "", MessageBoxButton.OKCancel);
                e.IsCancel = result == MessageBoxResult.Cancel;
            }
        }

        void EventMonitor_WidgetMinimized(object sender, WidgetEventArgs e)
        {
            if ((sender as WidgetControl).Child.GetHashCode() == this.GetHashCode())// 确定当前触发事件的内容为自身
            {
                MessageBoxResult result = MessageBox.Show("是否可以最小化窗口？", "", MessageBoxButton.OKCancel);
                e.IsCancel = result == MessageBoxResult.Cancel;
            }
        }

        void EventMonitor_WidgetCloseing(object sender, WidgetEventArgs e)
        {
            if ((sender as WidgetControl).Child.GetHashCode() == this.GetHashCode())// 确定当前触发事件的内容为自身
            {
                MessageBoxResult result = MessageBox.Show("是否可以关闭窗口？", "", MessageBoxButton.OKCancel);
                e.IsCancel = result == MessageBoxResult.Cancel;
            }
            //throw new System.NotImplementedException();
        }

        private void OpenTopic(object sender, RoutedEventArgs e)
        {
            Q.ToolbarManager.Show();
        }

        private void HideTopic(object sender, RoutedEventArgs e)
        {
            Q.ToolbarManager.Hide();
        }
    }
}
